how to deploy v2ray client on k8s

  1. create a configmap

    kubectl create configmap v2ray --from-file=/etc/v2ray/config.json
    
  2. create a pod

    an example yaml file:

    apiVersion: v1
    kind: Pod
    metadata:
      name: v2ray
    spec:
      nodeName: node
      containers:
        - name: v2ray
          image: v2ray/official
          volumeMounts:
          - name: v2ray
            mountPath: /etc/v2ray/config.json
            subPath: config.json
          imagePullPolicy: IfNotPresent
          command: [ "/bin/sh" ]
          args: ["-c","v2ray -config=/etc/v2ray/config.json"]
      volumes:
      - name: v2ray
        configMap:
          name: v2ray
    
    kubectl create -f pod.yaml
    
  3. create a pod label

    kubectl get pod --show-labels
    kubectl label pod v2ray app=v2ray
    
  4. create a service

    an example yaml file:

    apiVersion: v1
    kind: Service
    metadata:
      name: v2ray
    spec:
      selector:
        app: v2ray
      type: NodePort
      ports:
        - protocol: TCP
          port: 1080
          targetPort: 1080
          nodePort: 30000
    
    kubectl create -f service.yaml
    

at last, you can use tcpdump port 10080 to monitor network traffic comes from k8s master(if used) and node on v2ray server.